﻿
CREATE TRIGGER [trsec_t_Tracker__Status]
ON [dbo].[t_Tracker] 
FOR UPDATE
AS

IF NOT UPDATE (StatusID) RETURN

INSERT INTO t_ObjectStatus(ObjectName,Key_1,FromID,ToID)
SELECT OBJECT_NAME(st.parent_id),i.Counter,ISNULL(d.StatusID,0),i.StatusID
FROM inserted i LEFT JOIN deleted d ON i.ID = d.ID
CROSS JOIN sys.triggers st
where object_id = @@PROCID
